package com.fy.fyspace.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fy.fyspace.model.entity.FavoritePicture;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 图片 Mapper 接口
 * </p>
 *
 * @author fwq
 * @since 2025-06-25
 */
@Mapper
public interface FavoritePictureMapper extends BaseMapper<FavoritePicture> {

    /**
     * 查询所有状态的收藏记录（包括已逻辑删除）
     */
    @Select("SELECT * FROM favoritepicture WHERE picId = #{picId} AND favoriteUserId = #{userId} LIMIT 1")
    FavoritePicture selectAllStatusByPicIdAndUserId(@Param("picId") Long picId, @Param("userId") Long userId);

    /**
     * 修改图片收藏状态
     * @param id
     * @param status
     * @param date
     */
    @Update("update favoritepicture set isDelete = #{status}, updateTime = #{date} where id = #{id}")
    void updateStatus(Long id, Integer status, java.util.Date date);

    /**
     * 修改图片收藏状态
     * @param isDelete
     * @param date
     * @param id
     */
    @Update("update favoritepicture set isDelete = #{isDelete}, updateTime = #{date} where id = #{id}")
    void updateIsDeleteById(Integer isDelete, java.util.Date date, Long id);

}
